package org.example.java.lang;


import java.io.FileInputStream;
import java.io.IOException;

public class TestMySecurityManager {
  static class MySecurityManager extends SecurityManager {

    @Override
    public void checkRead(String file) {
//      super.checkRead(file, context);
      if (file.equals("data/test.txt"))
        throw new SecurityException("你没有读取的本文件的权限");
    }

  }

  public static void main(String[] args) {
    System.setSecurityManager(new MySecurityManager());
    try {
      FileInputStream fis = new FileInputStream("data/test.txt");
      System.out.println(fis.read());
    } catch (IOException e) {
      e.printStackTrace();
    }

  }
}

